package com.awesome.viewmodeldemo;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.ViewModel;

/**
 * Author: zhangjingfang
 * Email:zhangjingfang@jeejio.com
 * Date: 2021/7/30 13:00
 * Description:类描述
 */
public class MyViewModel extends ViewModel {
    private MutableLiveData<String> name;
    public LiveData<String> getName(){
        if (name == null){
            name = new MutableLiveData<>();
            addName();
        }
        return name;
    }

    private void addName() {
        name.setValue("How are you?");
    }
} 
 
 